package cn.xk.basic.util;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 工具类：封装增删改的返回结果
 */
@Data//提高get,set,toString,hashCode,equals,全参，无参方法
@AllArgsConstructor//全参
@NoArgsConstructor//无参
public class AjaxResult {

    //响应给前端用户判断
    private Boolean success = true;
    //响应给前端字符串信息
    private String msg = "操作成功";
    //响应给前端任意类型的数据 - fastDfs，Object是超类，可以表示任意数据类型
    private Object obj;

    //操作成功就调这个
    public AjaxResult(Boolean success, String msg) {
        this.success = success;
        this.msg = msg;
    }

    //链式语法的改造
    public static AjaxResult me() {
        return new AjaxResult();
    }

    public AjaxResult setSuccess(Boolean success) {
        this.success = success;
        return this;
    }

    public AjaxResult setMsg(String msg) {
        this.msg = msg;
        return this;
    }

    public AjaxResult setObj(Object obj) {
        this.obj = obj;
        return this;
    }


}
